//-----------------------------------------------------------------------------
//
// @file	OpenGLRender.h
// @brief	Class to use opengl render
// @author	Vinod Melapudi
// @date	20Feb2010
//
//-----------------------------------------------------------------------------

#ifndef _OPENGLRENDER_H
#define _OPENGLRENDER_H

#include "Renderer.h"

// OpenGL header
#include <GL/gl.h>
#include <GL/glu.h>
#include "glext.h"
#pragma comment( lib, "opengl32.lib" )
#pragma comment( lib, "glu32.lib" )



//
// @class	OpenGLRender
// @brief	Singleton class to support opengl render
//
class OpenGLRender: public Renderer
{
public:
	static Renderer* GetInstance()
	{
		static OpenGLRender instance;
		return &instance;
	}

	// Public functions to init, render and uninit renderer
	bool	Init( HWND hWnd, int width, int height );
	void	PreRender();
	void	PostRender();
	void	UnInit();


	void	HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam );
	void	RenderText( const char* str, float x, float y );

	// VBO
	inline uint		LoadVBO( uint data_size, void* data );
	inline void		BindVBO( uint vbo );
	inline void		UnloadVBO( uint *vbo );


	// Shader
#ifdef SHADER_SUPPORT
	bool	LoadShaders( const char *vertexShaderFile, const char * fragmentShaderFile, 
						 uint &vtxShdrID, uint &fragShdrID, uint &shdrProgramID );
	void	BindShader( uint shdrProgramID );
	void	UnInitShader( uint vtxShdrID, uint fragShdrID, uint shdrProgramID );
#endif

private:
	OpenGLRender();
	~OpenGLRender();

	bool InitRenderDeviceCtx();
	void UnInitRenderDeviceCtx();


	HDC					m_device_ctx;			// Device context
	HGLRC				m_render_ctx;			// Render context

	GLuint				m_text_list;			// Text base for font
};

#endif